﻿using System;
using FluentAssertions;
using LINQPad.OpenAccess.Infrastructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace LINQPad.OpenAccess.Tests.Infrastructure
{
    [TestClass]
    public class ServiceLocatorFixture
    {
        [TestMethod]
        public void UsesNinjectBasedImplementationByDefault( )
        {
            var locator = ServiceLocator.Current;

            locator.Should( )
                   .NotBeNull( )
                   .And.BeOfType<NinjectBasedServiceLocator>( );
        }
        [TestMethod]
        public void SetDefaultServiceLocatorFailsOnNullValue( )
        {
            this.Invoking( e => ServiceLocator.Current = null )
                .ShouldThrow<ArgumentNullException>( );
        }
        [TestMethod]
        public void TestChangeDefaultServiceLocator( )
        {
            var mock = new Mock<IServiceLocator>( );

            ServiceLocator.Current = mock.Object;

            ServiceLocator.Current.Should( ).BeSameAs( mock.Object );
        }
    }
}
